﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _2_9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private string Rot13(string input)
        {
            char[] chars = input.ToCharArray();
            for (int i = 0; i < chars.Length; i++)
            {
                char c = chars[i];
                // 大写字母处理（文档提示：A-N轮转）
                if (c >= 'A' && c <= 'Z')
                {
                    c = (char)(c + 13);
                    if (c > 'Z') c = (char)(c - 26);
                }
                // 小写字母处理
                else if (c >= 'a' && c <= 'z')
                {
                    c = (char)(c + 13);
                    if (c > 'z') c = (char)(c - 26);
                }
                // 非字母字符不变
                chars[i] = c;
            }
            return new string(chars);
        }
        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string input = textBox1.Text;
            string output = Rot13(input);
            textBox2.Text = output;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
        }
    }
}

